package ControlLayer;
import ModelLayer.MachineryContainer;
import ModelLayer.Machinery;
import ModelLayer.Unit;
import java.util.ArrayList;
/**
 * Vestbjerg project
 * @GroupB2 (UCN - Computer Science DMAJ0914) 
 */
public class MachineryCtr
{
    // instance variables
    private MachineryContainer machineryContainer;

    /**
     * Constructor for objects of class MachineryCtr
     */
    public MachineryCtr()
    {
        machineryContainer = MachineryContainer.getInstance();
    }
    
    public void createMachinery(String barcode, String name, String description, double price)
    {
        Machinery machinery = new Machinery(barcode, name, description, price);
        machineryContainer.addMachinery(machinery);
    }
    
    public void updateMachinery(Machinery machinery, String barcode, String name, String description, double price)
    {
        machinery.setBarcode(barcode);
        machinery.setName(name);
        machinery.setDescription(description);
        machinery.setPrice(price);
    }
    
    public Machinery findMachinery(String barcode)
    {
        return machineryContainer.findMachinery(barcode);
    }
    
    public void deleteMachinery(Machinery machinery)
    {
        machineryContainer.deleteMachinery(machinery);
    }
    
    public void createUnit(Machinery machinery, String serialNumber)
    {
        Unit unit = new Unit(machinery,serialNumber);
        machinery.addUnit(unit);
    }
    
    public void updateUnit(Unit unit, String serialNumber)
    {
        unit.setSerialNumber(serialNumber);
    }
    
    public Unit findUnit(String serialNumber)
    {
         return machineryContainer.findUnit(serialNumber);
    }
    
    public void deleteUnit(Machinery machinery, Unit unit)
    {
        machinery.deleteUnit(unit);
    }
    
    public ArrayList<Machinery> getMachineryList() 
    {
     return machineryContainer.getMachineryList();
    }
}